//
//  GBArchitectureTests.m
//  GBArchitectureTests
//
//  Created by ceo on 2017/6/9.
//  Copyright © 2017年 chengb. All rights reserved.
//

#import <Kiwi/Kiwi.h>
#import "GBHTTPSessionManager.h"
#import "User.h"

//接口测试
SPEC_BEGIN(APITest)
describe(@"获取首页数据接口测试", ^{
    context(@"获取广告接口", ^{
        __block NSDictionary *fetchedData = nil;
        it(@"should receive data within one second", ^{
            [[GBHTTPSessionManager shared] GET:@"http://192.168.0.36:3000/" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                fetchedData = responseObject;
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                fetchedData = error.userInfo;
            }];
            [[[expectFutureValue(fetchedData) shouldEventuallyBeforeTimingOutAfter(5.0)] should] beNonNil];
        });
    });
});
SPEC_END



//业务逻辑测试
SPEC_BEGIN(BussnissTest)
describe(@"获取首页数据接口测试", ^{
    context(@"获取广告接口", ^{
        it(@"should receive data within one second", ^{
            __block NSString *fetchedData = nil;
            [[GBHTTPSessionManager shared] GET:@"http://192.168.0.36:3000/" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                fetchedData = @"ds";
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                fetchedData = @"ds";
            }];
            [[expectFutureValue(fetchedData) shouldEventuallyBeforeTimingOutAfter(5.0)] equal:@"ds"];
        });
        
    });
});
SPEC_END

//工具类测试
SPEC_BEGIN(UtilsTest)
describe(@"获取首页数据接口测试", ^{
    context(@"获取广告接口", ^{
        it(@"should receive data within one second", ^{
            __block NSString *fetchedData = nil;
            [[GBHTTPSessionManager shared] GET:@"http://192.168.0.36:3000/" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
                fetchedData = @"ds";
            } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
                fetchedData = @"ds";
            }];
            [[expectFutureValue(fetchedData) shouldEventuallyBeforeTimingOutAfter(5.0)] equal:@"ds"];
        });
        
    });
});
SPEC_END





